home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / common / destination_arrived.c4 < prev    next >
Text File  |  2003-01-03  |  12KB  |  242 lines

  1.       
  2. {
  3.   @destination_arrived {
  4.     resid Player;
  5.     resid Game;
  6.     resid CurCommodity;
  7.     resid Scenario;
  8.     str nav_cur_city;
  9.     str destination_city;
  10.     str game_stats;
  11.     str instruction;
  12.     int num_commodities;
  13.     int i;
  14.     int tmp_int;
  15.     str tmp_str;
  16.     str start_date;
  17.     str end_date;
  18.     int commodity_cost;
  19.     int bonus_commodity_cost;
  20.     int commodity_revenue;
  21.     str commodity_revenue_str;
  22.     int total_income;
  23.     str total_income_str;
  24.     int truck_lease_cost_per_day;
  25.     int truck_meter_cost_per_mile;
  26.     int truck_trip_meter_cost;
  27.     int truck_lease_cost;
  28.     int truck_lease_total_cost;
  29.     str truck_lease_total_cost_str;
  30.     str total_expense_str;
  31.     int total_expense;
  32.     int fuel_expense;
  33.     str fuel_expense_str;    
  34.     int food_expense;
  35.     str food_expense_str;
  36.     int hotel_expense;
  37.     str hotel_expense_str;
  38.     int mishap_expense;
  39.     str mishap_expense_str;
  40.     int ticket_expense;
  41.     str ticket_expense_str;
  42.     int total;
  43.     str total_str;
  44.     str commodity_str;
  45.     
  46.     Game             = ResByName("Game");
  47.     Player           = ResPropGetResID(Game,"game_cur_player");
  48.     Scenario         = ResPropGetResID(Player,"scenario_id"); 
  49.     destination_city = ResPropGetStr(Scenario,"scenario_end_city");
  50.     nav_cur_city     = ResPropGetStr(Player,"nav_cur_city");
  51.     num_commodities  = ResPropGetInt(Scenario,"scenario_commodity_number_of");
  52.     
  53.     /* stop if this city is not the destination city */
  54.     if (! StrExact(nav_cur_city,destination_city)) {
  55.       stop;
  56.     }
  57.  
  58.     if (ResPropGetInt(Player, "player_destination_arrived") == 1) { stop; }
  59.  
  60.     i = 1;
  61.     while (i <= num_commodities) {
  62.       CurCommodity = ResPropGetResID(Player,StrFormatStr("commodity_%d",i));
  63.       if (ResPropGetInt(CurCommodity,"commodity_state") != 1) {
  64.         stop;
  65.       }
  66.       i += 1;
  67.     }
  68.     
  69.     
  70.     
  71.     
  72.     /* print the game stats to the travel log */
  73.     StrListAppend( ResPropGetResID(Player, "travel_log"), "-----------------------------------------------------------------"); 
  74.    
  75.    
  76.  
  77.     
  78.    
  79.  
  80.     tmp_int    = ResPropGetInt(Scenario,"scenario_start_date");
  81.     start_date = StrFormatStr("%s %d, %d", StrCapFirst(TimeGetMonthStr(tmp_int)), TimeGetDay(tmp_int), TimeGetYear(tmp_int)); 
  82.     tmp_int    = ResPropGetInt(Player,"time_now");
  83.     tmp_int   += (ResPropGetInt(Player,"time_zone_clock_offset") * 60);   
  84.     end_date   = StrFormatStr("%s %d, %d", StrCapFirst(TimeGetMonthStr(tmp_int)), TimeGetDay(tmp_int), TimeGetYear(tmp_int)); 
  85.  
  86.     StrListAppend( ResPropGetResID(Player, "travel_log"), " "); 
  87.     StrListAppend( ResPropGetResID(Player, "travel_log"), "Assignment:");   
  88.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(274/*"    Driver: %s"*/), ResPropGetStr(Player,"player_name")));
  89.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(275/*"    Start Location: %s"*/), ResPropGetStr(Scenario,"scenario_start_city")));
  90.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(276/*"    Destination: %s"*/), ResPropGetStr(Scenario,"scenario_end_city")));
  91.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(277/*"    Start Date: %s"*/), start_date));
  92.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(278/*"    End Date: %s"*/), end_date));
  93.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(279/*"    Total Mileage: %d %s"*/), ResPropGetInt(Player,"truck_trip_meter"), ResPropGetStr(Game,"game_distance_unit")));
  94.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(280/*"    Bonus Commodity: %s"*/), ResPropGetStr(Scenario,"scenario_commodity_bonus")));    
  95.  
  96.     
  97.  
  98.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_1"),"")) {
  99.       commodity_str = ResPropGetStr(Scenario,"scenario_commodity_name_1");
  100.     }
  101.  
  102.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_2"),"")) {
  103.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_2"));
  104.     }
  105.  
  106.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_3"),"")) {
  107.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_3"));
  108.     }
  109.  
  110.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_4"),"")) {
  111.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_4"));
  112.     }
  113.  
  114.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_5"),"")) {
  115.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_5"));
  116.     }
  117.     
  118.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_6"),"")) {
  119.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_6"));
  120.     }    
  121.     
  122.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_7"),"")) {
  123.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_7"));
  124.     }
  125.  
  126.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_8"),"")) {
  127.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_8"));
  128.     }
  129.     
  130.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_9"),"")) {
  131.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_9"));
  132.     }
  133.     
  134.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_10"),"")) {
  135.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_10"));
  136.     }
  137.     
  138.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_11"),"")) {
  139.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_11"));
  140.     }    
  141.  
  142.     if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_12"),"")) {
  143.       commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_12"));
  144.     }
  145.     
  146.   
  147.         
  148.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(281/*"    Commodities:     %s"*/),commodity_str));
  149.     StrListAppend( ResPropGetResID(Player, "travel_log"), " "); 
  150.     StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(282/*"Income:"*/));  
  151.  
  152.     /* get number of commodity player picked up */
  153.     commodity_cost = ResPropGetInt(Game,"game_salary_per_commodity");
  154.     bonus_commodity_cost = ResPropGetInt(Game,"game_salary_bonus_commodity");
  155.         commodity_revenue = ResPropGetInt(Player,"commodity_number_of") * commodity_cost;
  156.         
  157.     /* check bonus commodity */
  158.     if (ResPropGetInt(ResPropGetResID(Player, "commodity_bonus"),"commodity_state") == 1) {      
  159.       commodity_revenue += bonus_commodity_cost;
  160.     }
  161.     
  162.     commodity_revenue_str = StrFormatStr(MangleSIDToStr(283/*"$ %s"*/), IntToDecimalStr(commodity_revenue,100));
  163.     
  164.     total_income = commodity_revenue + ResPropGetInt(Player, "expense_cash_in_hand");
  165.     total_income_str = StrFormatStr(MangleSIDToStr(284/*"$ %s"*/), IntToDecimalStr(total_income,100));
  166.  
  167.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(285/*"    Starting Balance: $%s\n"*/), IntToDecimalStr(ResPropGetInt(Player, "expense_cash_in_hand"),100)));
  168.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(286/*"    Commodity Revenue: %s\n"*/), commodity_revenue_str));
  169.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(287/*"    Total Income: %s\n"*/), total_income_str));
  170.  
  171.     StrListAppend( ResPropGetResID(Player, "travel_log"), " "); 
  172.     StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(288/*"Expenses:"*/));  
  173.  
  174.     truck_lease_cost_per_day = ResPropGetInt(Game,"game_truck_lease_cost_per_day");
  175.     truck_meter_cost_per_mile = ResPropGetInt(Game,"game_truck_meter_cost_per_mile");
  176.  
  177.     food_expense = ResPropGetInt(Player, "expense_spent_on_food");
  178.       total_expense += food_expense;  
  179.       food_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(food_expense,100));
  180.                                
  181.       fuel_expense = ResPropGetInt(Player, "expense_spent_on_fuel");
  182.     fuel_expense += ((ResPropGetInt(Game,"game_tank_capacity") - ResPropGetInt(Player,"truck_fuel_remaining")) * ResPropGetInt(Game,"game_fuel_unit_cost")) / 1000;
  183.     ResPropSetInt(Player,"truck_fuel_remaining",ResPropGetInt(Game,"game_tank_capacity"));
  184.     ResPropSetInt(Player, "expense_spent_on_fuel",fuel_expense);
  185.       total_expense += fuel_expense;
  186.     fuel_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(fuel_expense,100)); 
  187.  
  188.       hotel_expense = ResPropGetInt(Player, "expense_spent_on_hotel");
  189.       total_expense += hotel_expense;
  190.     hotel_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(hotel_expense,100)); 
  191.      
  192.       mishap_expense = ResPropGetInt(Player, "expense_spent_on_mishap");
  193.       total_expense += mishap_expense;      
  194.     mishap_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(mishap_expense,100)); 
  195.  
  196.       ticket_expense = ResPropGetInt(Player, "expense_spent_on_ticket");
  197.       total_expense += ticket_expense;      
  198.     ticket_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(ticket_expense,100));                        
  199.  
  200.     /* display truck lease cost */
  201.     truck_trip_meter_cost = ResPropGetInt(Player, "truck_trip_meter") * truck_meter_cost_per_mile;
  202.     truck_lease_cost = (TimeGetDay(ResPropGetInt(Player, "time_now"))-1) * truck_lease_cost_per_day;
  203.     truck_lease_total_cost = (truck_trip_meter_cost + truck_lease_cost)/10;
  204.     total_expense += truck_lease_total_cost;
  205.     truck_lease_total_cost_str = StrFormatStr("($ %s)", IntToDecimalStr(truck_lease_total_cost,100));      
  206.  
  207.     total_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(total_expense,100)); 
  208.  
  209.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(289/*"    Food Cost: %s"*/), food_expense_str));
  210.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(290/*"    Fuel / Ferry Cost: %s"*/), fuel_expense_str ));
  211.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(291/*"    Lodging Cost: %s"*/), hotel_expense_str));
  212.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(292/*"    Mishap Cost: %s"*/), mishap_expense_str));
  213.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(293/*"    Ticket Cost: %s"*/), ticket_expense_str));
  214.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(294/*"    Truck Lease: %s"*/), truck_lease_total_cost_str));
  215.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(295/*"    Total Expenses: %s"*/), total_expense_str));
  216.  
  217.     total = total_income - total_expense;
  218.     
  219.     if ( total < 0 ) {
  220.       total *= -1;
  221.       total_str = StrFormatStr("($ %s)", IntToDecimalStr(total,100));
  222.     } else {
  223.       total_str = StrFormatStr("$ %s", IntToDecimalStr(total,100));
  224.     }
  225.  
  226.     StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
  227.     StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(296/*"Profit / (Loss): %s"*/), total_str));
  228.     StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
  229.     StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(297/*"Congratulations, you have successfully completed your assignment!"*/));      
  230.  
  231.     /* set the dest flag */
  232.     ResPropSetInt(Player,"player_destination_arrived",1);
  233.  
  234.     /* load full screen animation */
  235.     ResPropSetStr(Player, "nav_picture", "victory");
  236.     ResPropSetStr(Player, "nav_sound", "victory");
  237.     ResPropSetInt(Player, "nav_switch_player", 1);
  238.     ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
  239.     ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);
  240.   }
  241. }
  242.